<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>原料仓库管理系统</title>
</head>
<?php
session_start();
if ($_SESSION['username']!=null){
	
}else{
	 echo"<script type='text/javascript'>location='CKGL-index.php';
			</script>";
}
?>

<?php 
require('lianjie.php');
?>
<link rel="stylesheet" type="text/css" href="css/ckgl_cw.css" />
<body>
<a href="CKGL_no1.php">返回首页</a>
<div class="box_nn">
<form action="CKGL_cw.php" method="POST" name="f1">
<table align="center" width="100%" border="1" cellpadding="1" cellspacing="1" bordercolor="#000000" bgcolor="#c3c3c3">
<tr>
<td align="center"><input type="date" name="d1" value="<?php echo date('Y-m-d',strtotime('-1 month')); ?>" />~<input type="date" name="d2" value="<?php echo date('Y-m-d'); ?>" /></td>
<td>厂商:<input type="text" name="LY" value="" /></td>
<td align="center">请输入储位:<input type="text" name="KQ" value="" /></td>
</tr>
<tr>
<td align="center">请输入原料名称:<input type="text" name="name" value="" /></td>
<td align="center">请输入原料批号:<input type="text" name="PH" value="" /></td>
<td align="center">请输入原料手册号:<input type="text" name="id" value="" /></td>
<td><input type="submit" name="sub" value="确定" />&nbsp;&nbsp;&nbsp;&nbsp;<input type="reset" name="rst" value="清除" /></td>
</tr>
</table>
</form>
</div>

<div class="box_CZJL">
<tr>
<td>现有库区存储数据</td>
</tr>
<table align="center" width="100%" border="1" cellpadding="1" cellspacing="1" bordercolor="#000000" bgcolor="#c3c3c3" style="font-size:9px">

<?php
if(isset($_POST['name']) or isset($_POST['PH']) or isset($_POST['id']) or isset($_POST['CW'])){
	$d1=$_POST['d1'];
	$d2=$_POST['d2'];
	if(isset($_POST['name'])){
		$n="'%".$_POST['name']."%'";
	}
	else{$n="'%%'";}
	if(isset($_POST['PH'])){
		$p="'%".$_POST['PH']."%'";
	}
	else{$p="'%%'";}
	if(isset($_POST['id'])){
		$i="'%".$_POST['id']."%'";
	}
	else{$i="'%%'";}
	if(isset($_POST['LY'])){
		$l="'%".$_POST['LY']."%'";
	}
	else{$l="'%%'";}
	if(isset($_POST['KQ'])){
		$k="'%".$_POST['KQ']."%'";
	}
	else{$k="'%%'";}
	?>
    <thead>
    <tr>
    <th>时间</th>
    <th>表类别</th>
    <th>原料类型</th>
    <th>名称</th>
    <th>批号</th>
    <th>手册号</th>
    <th>库区</th>
    <th>入库包数</th>
    <th>出库包数</th>
    <th>结存包数</th>
    <th>入库实物量</th>
    <th>出库实物量</th>
    <th>结存实物量</th>
    </tr>
    </thead>
    <?php
	if(mysqli_select_db($connID,$dbName)){
		$sql="select r.dh_date,r.BLB,r.YLLB,r.name,r.PH,r.id,r.KQ,r.BS,c.BS,(r.BS-ifnull(c.BS,0)),r.SW,c.SW,(r.SW-ifnull(c.SW,0)) from (select dh_date,name,PH,id,KQ,sum(BS) as BS,sum(SW) as SW,sum(GU) as GU,sum(NIE) as NIE,sum(MENG) as MENG,sum(TONG) as TONG,sum(LI) as LI,BLB,YLLB,LY from rkb group by name,PH,id) as r left join (select name,PH,id,KQ,sum(BS) as BS,sum(SW) as SW,sum(GU) as GU,sum(NIE) as NIE,sum(MENG) as MENG,sum(TONG) as TONG,sum(LI) as LI from ckb group by name,PH,id) as c on r.name=c.name and r.PH=c.PH and r.id=c.id where (r.name like".$n." and r.PH like".$p." and r.id like".$i." and r.KQ like".$k." and r.LY like ".$l.") and (r.dh_date>='".$d1."' and r.dh_date<='".$d2."') and r.KQ<>'';";
		//echo $sql;
		$sum=12;
		$arr=array(0=>$sum,1=>'17',2=>'储位信息',3=>'时间',4=>'表类别',5=>'原料类型',6=>'名称',7=>'批号',8=>'手册号',9=>'库区',10=>'入库包数',11=>'出库包数',12=>'结存包数',13=>'入库实物量',14=>'出库实物量',15=>'结存实物量',16=>"".$sql."");
		$url1='Excel_dy.php?'.http_build_query($arr);
		$result=mysqli_query($connID,$sql);
		while($myrow=mysqli_fetch_array($result)){
			if($myrow[9]!=0){
				?>
                <tr>
                <td align="center"><span class="STYLE2"><?php echo $myrow[0];?></span></td>
                <td align="center"><span class="STYLE2"><?php echo $myrow[1];?></span></td>
                <td align="center"><span class="STYLE2"><?php echo $myrow[2];?></span></td>
                <td align="center"><span class="STYLE2"><?php echo $myrow[3];?></span></td>
                <td align="center"><span class="STYLE2"><?php echo $myrow[4];?></span></td>
                <td align="center"><span class="STYLE2"><?php echo $myrow[5];?></span></td>
                <td align="center"><span class="STYLE2"><?php echo $myrow[6];?></span></td>
                <td align="center"><span class="STYLE2"><?php echo $myrow[7];?></span></td>
                <td align="center"><span class="STYLE2"><?php echo $myrow[8];?></span></td>
                <td align="center"><span class="STYLE2"><?php echo $myrow[9];?></span></td>
                <td align="center"><span class="STYLE2"><?php echo $myrow[10];?></span></td>
                <td align="center"><span class="STYLE2"><?php echo $myrow[11];?></span></td>
                <td align="center"><span class="STYLE2"><?php echo $myrow[12];?></span></td>
                </tr>
                <?php
			}
		}
	}
}
else{
	?>
    <thead>
    <tr>
    <th>时间</th>
    <th>表类别</th>
    <th>原料类型</th>
    <th>名称</th>
    <th>批号</th>
    <th>手册号</th>
    <th>库区</th>
    <th>入库包数</th>
    <th>出库包数</th>
    <th>结存包数</th>
    <th>入库实物量</th>
    <th>出库实物量</th>
    <th>结存实物量</th>
    </tr>
    </thead>
    <?php
	if(mysqli_select_db($connID,$dbName)){
		$sql="select r.dh_date,r.BLB,r.YLLB,r.name,r.PH,r.id,r.KQ,r.BS,c.BS,(r.BS-ifnull(c.BS,0)),r.SW,c.SW,(r.SW-ifnull(c.SW,0)) from (select dh_date,name,PH,id,KQ,sum(BS) as BS,sum(SW) as SW,sum(GU) as GU,sum(NIE) as NIE,sum(MENG) as MENG,sum(TONG) as TONG,sum(LI) as LI,BLB,YLLB,LY from rkb group by name,PH,id) as r left join (select name,PH,id,KQ,sum(BS) as BS,sum(SW) as SW,sum(GU) as GU,sum(NIE) as NIE,sum(MENG) as MENG,sum(TONG) as TONG,sum(LI) as LI from ckb group by name,PH,id) as c on r.name=c.name and r.PH=c.PH and r.id=c.id where r.KQ<>'';";
		//echo $sql;
		$sum=12;
		$arr=array(0=>$sum,1=>'17',2=>'储位信息',3=>'时间',4=>'表类别',5=>'原料类型',6=>'名称',7=>'批号',8=>'手册号',9=>'库区',10=>'入库包数',11=>'出库包数',12=>'结存包数',13=>'入库实物量',14=>'出库实物量',15=>'结存实物量',16=>"".$sql."");
		$url1='Excel_dy.php?'.http_build_query($arr);
		$result=mysqli_query($connID,$sql);
		while($myrow=mysqli_fetch_array($result)){
			if($myrow[9]!=0){
				?>
                <tr>
                <td align="center"><span class="STYLE2"><?php echo $myrow[0];?></span></td>
                <td align="center"><span class="STYLE2"><?php echo $myrow[1];?></span></td>
                <td align="center"><span class="STYLE2"><?php echo $myrow[2];?></span></td>
                <td align="center"><span class="STYLE2"><?php echo $myrow[3];?></span></td>
                <td align="center"><span class="STYLE2"><?php echo $myrow[4];?></span></td>
                <td align="center"><span class="STYLE2"><?php echo $myrow[5];?></span></td>
                <td align="center"><span class="STYLE2"><?php echo $myrow[6];?></span></td>
                <td align="center"><span class="STYLE2"><?php echo $myrow[7];?></span></td>
                <td align="center"><span class="STYLE2"><?php echo $myrow[8];?></span></td>
                <td align="center"><span class="STYLE2"><?php echo $myrow[9];?></span></td>
                <td align="center"><span class="STYLE2"><?php echo $myrow[10];?></span></td>
                <td align="center"><span class="STYLE2"><?php echo $myrow[11];?></span></td>
                <td align="center"><span class="STYLE2"><?php echo $myrow[12];?></span></td>
                </tr>
                <?php
			}
		}
	}
}
?>

</table>
</div>

<div class="box_CZJL1">
<tr>
<td>所有库区存储数据</td>
</tr>
<table align="center" width="100%" border="1" cellpadding="1" cellspacing="1" bordercolor="#000000" bgcolor="#c3c3c3" style="font-size:9px">

<?php
if(isset($_POST['name']) or isset($_POST['PH']) or isset($_POST['id']) or isset($_POST['CW'])){
	$d1=$_POST['d1'];
	$d2=$_POST['d2'];
	if(isset($_POST['name'])){
		$n="'%".$_POST['name']."%'";
	}
	else{$n="'%%'";}
	if(isset($_POST['PH'])){
		$p="'%".$_POST['PH']."%'";
	}
	else{$p="'%%'";}
	if(isset($_POST['id'])){
		$i="'%".$_POST['id']."%'";
	}
	else{$i="'%%'";}
	if(isset($_POST['LY'])){
		$l="'%".$_POST['LY']."%'";
	}
	else{$l="'%%'";}
	if(isset($_POST['KQ'])){
		$k="'%".$_POST['KQ']."%'";
	}
	else{$k="'%%'";}
	?>
    <thead>
    <tr>
    <th>时间</th>
    <th>表类别</th>
    <th>原料类型</th>
    <th>名称</th>
    <th>批号</th>
    <th>手册号</th>
    <th>库区</th>
    <th>入库包数</th>
    <th>出库包数</th>
    <th>结存包数</th>
    <th>入库实物量</th>
    <th>出库实物量</th>
    <th>结存实物量</th>
    </tr>
    </thead>
    <?php
	if(mysqli_select_db($connID,$dbName)){
		$sql="select r.dh_date,r.BLB,r.YLLB,r.name,r.PH,r.id,r.KQ,r.BS,c.BS,(r.BS-ifnull(c.BS,0)),r.SW,c.SW,(r.SW-ifnull(c.SW,0)) from (select dh_date,name,PH,id,KQ,sum(BS) as BS,sum(SW) as SW,sum(GU) as GU,sum(NIE) as NIE,sum(MENG) as MENG,sum(TONG) as TONG,sum(LI) as LI,BLB,YLLB,LY from rkb group by name,PH,id) as r left join (select name,PH,id,KQ,sum(BS) as BS,sum(SW) as SW,sum(GU) as GU,sum(NIE) as NIE,sum(MENG) as MENG,sum(TONG) as TONG,sum(LI) as LI from ckb group by name,PH,id) as c on r.name=c.name and r.PH=c.PH and r.id=c.id where (r.name like".$n." and r.PH like".$p." and r.id like".$i." and r.KQ like".$k." and r.LY like ".$l.") and (r.dh_date>='".$d1."' and r.dh_date<='".$d2."') and r.KQ<>'';";
		//echo $sql;
		$sum=12;
		$arr1=array(0=>$sum,1=>'17',2=>'储位信息',3=>'时间',4=>'表类别',5=>'原料类型',6=>'名称',7=>'批号',8=>'手册号',9=>'库区',10=>'入库包数',11=>'出库包数',12=>'结存包数',13=>'入库实物量',14=>'出库实物量',15=>'结存实物量',16=>"".$sql."");
		$url2='Excel_dy.php?'.http_build_query($arr1);
		$result=mysqli_query($connID,$sql);
		while($myrow=mysqli_fetch_array($result)){
			
				?>
                <tr>
                <td align="center"><span class="STYLE2"><?php echo $myrow[0];?></span></td>
                <td align="center"><span class="STYLE2"><?php echo $myrow[1];?></span></td>
                <td align="center"><span class="STYLE2"><?php echo $myrow[2];?></span></td>
                <td align="center"><span class="STYLE2"><?php echo $myrow[3];?></span></td>
                <td align="center"><span class="STYLE2"><?php echo $myrow[4];?></span></td>
                <td align="center"><span class="STYLE2"><?php echo $myrow[5];?></span></td>
                <td align="center"><span class="STYLE2"><?php echo $myrow[6];?></span></td>
                <td align="center"><span class="STYLE2"><?php echo $myrow[7];?></span></td>
                <td align="center"><span class="STYLE2"><?php echo $myrow[8];?></span></td>
                <td align="center"><span class="STYLE2"><?php echo $myrow[9];?></span></td>
                <td align="center"><span class="STYLE2"><?php echo $myrow[10];?></span></td>
                <td align="center"><span class="STYLE2"><?php echo $myrow[11];?></span></td>
                <td align="center"><span class="STYLE2"><?php echo $myrow[12];?></span></td>
                </tr>
                <?php
			
		}
	}
}
else{
	?>
    <thead>
    <tr>
    <th>时间</th>
    <th>表类别</th>
    <th>原料类型</th>
    <th>名称</th>
    <th>批号</th>
    <th>手册号</th>
    <th>库区</th>
    <th>入库包数</th>
    <th>出库包数</th>
    <th>结存包数</th>
    <th>入库实物量</th>
    <th>出库实物量</th>
    <th>结存实物量</th>
    </tr>
    </thead>
    <?php
	if(mysqli_select_db($connID,$dbName)){
		$sql="select r.dh_date,r.BLB,r.YLLB,r.name,r.PH,r.id,r.KQ,r.BS,c.BS,(r.BS-ifnull(c.BS,0)),r.SW,c.SW,(r.SW-ifnull(c.SW,0)) from (select dh_date,name,PH,id,KQ,sum(BS) as BS,sum(SW) as SW,sum(GU) as GU,sum(NIE) as NIE,sum(MENG) as MENG,sum(TONG) as TONG,sum(LI) as LI,BLB,YLLB,LY from rkb group by name,PH,id) as r left join (select name,PH,id,KQ,sum(BS) as BS,sum(SW) as SW,sum(GU) as GU,sum(NIE) as NIE,sum(MENG) as MENG,sum(TONG) as TONG,sum(LI) as LI from ckb group by name,PH,id) as c on r.name=c.name and r.PH=c.PH and r.id=c.id where r.KQ!='';";
		//echo $sql;
		$sum=12;
		$arr1=array(0=>$sum,1=>'17',2=>'储位信息',3=>'时间',4=>'表类别',5=>'原料类型',6=>'名称',7=>'批号',8=>'手册号',9=>'库区',10=>'入库包数',11=>'出库包数',12=>'结存包数',13=>'入库实物量',14=>'出库实物量',15=>'结存实物量',16=>"".$sql."");
		$url2='Excel_dy.php?'.http_build_query($arr1);
		$result=mysqli_query($connID,$sql);
		while($myrow=mysqli_fetch_array($result)){
			
				?>
                <tr>
                <td align="center"><span class="STYLE2"><?php echo $myrow[0];?></span></td>
                <td align="center"><span class="STYLE2"><?php echo $myrow[1];?></span></td>
                <td align="center"><span class="STYLE2"><?php echo $myrow[2];?></span></td>
                <td align="center"><span class="STYLE2"><?php echo $myrow[3];?></span></td>
                <td align="center"><span class="STYLE2"><?php echo $myrow[4];?></span></td>
                <td align="center"><span class="STYLE2"><?php echo $myrow[5];?></span></td>
                <td align="center"><span class="STYLE2"><?php echo $myrow[6];?></span></td>
                <td align="center"><span class="STYLE2"><?php echo $myrow[7];?></span></td>
                <td align="center"><span class="STYLE2"><?php echo $myrow[8];?></span></td>
                <td align="center"><span class="STYLE2"><?php echo $myrow[9];?></span></td>
                <td align="center"><span class="STYLE2"><?php echo $myrow[10];?></span></td>
                <td align="center"><span class="STYLE2"><?php echo $myrow[11];?></span></td>
                <td align="center"><span class="STYLE2"><?php echo $myrow[12];?></span></td>
                </tr>
                <?php
			
		}
	}
}
?>

</table>
</div>

<a href="<?php echo $url1;?>"><div class="tz">导出</div></a>
<a href="<?php echo $url2;?>"><div class="tz2">导出</div></a>
</body>
</html>